import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import TaskApi from '../api/TaskApi';
import { Task, TaskType } from '../entity/Task';
import { MainTaskItem } from './MainTaskItem';
import { UIManager } from '../common/UIManager';
const { ccclass, property } = _decorator;

@ccclass('MainTask')
export class MainTask extends Component {
    @property(Node)
    content:Node
    @property(Prefab)
    mainTaskItem:Prefab
    
    async start() {
       await UIManager.instance.showLoading()
       let list = await Task.getTaskListByType(TaskType.Main)
       UIManager.instance.closeLoading()
       
       console.log(list)


       for(let item of list){
         let node = instantiate(this.mainTaskItem)
         this.content.addChild(node)
         node.getComponent(MainTaskItem).setData(item)
       }
    }
}


